<template>
    <div class="fillcontain">
        <el-form :model="formData" label-position="labelPosition" ref="formData"
                 class="demo-form-inline" style="margin-left: 10px;margin-right: 10px">
            <el-row>
                <el-col :span="6">
                    <el-form-item label="">
                        <el-input

                            size="mini" style="width: 220px"
                            placeholder="请输入新密码"
                            prefix-icon="el-icon-search"
                            v-model="formData.password">
                        </el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="6">
                    <el-button type="primary" @click="this.initData" size="mini" icon="el-icon-search">重置密码</el-button>
                </el-col>
            </el-row>
        </el-form>
    </div>

</template>

<script>
    import {mapActions, mapState, mapGetters} from 'vuex'
    import headTop from '../components/headTop'
    import {getUserList, getUserCount, updatePwd} from '@/api/getData'

    export default {
        computed: {
            ...mapGetters(['adminInfo'])
        },

        data() {
            return {
                formData: {},
            }
        },
        components: {
            headTop,
        },
        created() {
            //this.initData();
        },
        methods: {
            async initData() {
                try {
                    if (this.formData.password == null) {
                        alert("新密码不允许为空!");
                        return;
                    }
                    const v = await updatePwd({
                        "data": {
                            "cid": this.adminInfo.cid,
                            "password": this.formData.password
                        }
                    });

                    if (v.success == true) {
                        this.$message({
                            type: 'success',
                            message: '修改密码成功!'
                        });
                    }
                } catch (err) {
                    console.log('修改密码失败', err);
                }
            }
        }
    }
</script>
